
import { createApp } from 'vue'
import pinia from '@/stores/index'

import App from './App.vue'
import router from './router'

// 导入 ElementPlus 相关
import { initElement } from '@/tools/elementInit'
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import 'virtual:svg-icons-register'
// 公共样式
import '@/styles/index.scss';
// 字体样式
import '@/assets/fonts/font.scss'

// 组件注册
import registerGlobComp from './components'
// 指令注册

// 加载异步路由
import '@/router/initRouter'

const setupApp =async () => {
	const app = createApp(App)
	// 初始化 Element plus
	initElement(app)
	// 持久化
	app.use(pinia)
	// 路由
	app.use(router)
	// 全局组件注册
	app.use(registerGlobComp)

	 return app
}

setupApp().then((app) =>{
	app.mount('#app')
	// 导入全部的 Element-icon
	for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
		app.component(key, component);
		
	}
})
